﻿using Persistencia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dlls
{
  public  class OperacoesDLL
    {
      Context context;

      public OperacoesDLL()
      {
          context = new Context();
      }
      public IEnumerable<Operacoe> List()
      {
          return (from o in context.Operacoes select o).ToList();
      }
      public void Insert(Operacoe operacoes)
      {
          context.Operacoes.InsertOnSubmit(operacoes);
          context.SubmitChanges();
      }
      public void Delete(int Codigo)
      {
          Operacoe operacoes = context.Operacoes.Single(o => o.Codigo == Codigo);
          context.Operacoes.DeleteOnSubmit(operacoes);
          context.SubmitChanges();
      }
      public void Update(int Codigo, Operacoe operacao)
      {
          Operacoe op = context.Operacoes.SingleOrDefault(o => o.Codigo == Codigo);
          op.GeraFinanceiro = operacao.GeraFinanceiro;
          op.AtivoSN = operacao.AtivoSN;
          op.Nome = operacao.Nome;
          context.SubmitChanges();
      }
      public Operacoe getOperacoes(int codigo)
      {
          return context.Operacoes.SingleOrDefault(e => e.Codigo == codigo);
      }
     
    }
}
